//
//  ZHomeViewModel.m
//  OC-weibo
//
//  Created by zero on 17/3/24.
//  Copyright © 2017年 zero. All rights reserved.
//

#import "ZHomeViewModel.h"

@implementation ZHomeViewModel


#pragma mark
#pragma mark - 加载home数据
- (void)homeDataViewModel:(void(^)(BOOL res) )finishBlacok{
    
    [[ZNetworkTool shareNetworkTool] homeLoadSuccess:^(NSDictionary *responseObject) {
        
        //  转模型
        NSArray <ZUserModel *>*tempArray = [NSArray yy_modelArrayWithClass:[ZUserModel class] json:responseObject[@"statuses"]];
        

//        NSLog(@"%@",tempArray.firstObject.pic_urls.);
        
        //  初始化
        self.homeModelList = [NSMutableArray array];
        
        //  遍历添加
        for (ZUserModel *userModel in tempArray) {
            
            ZHomeModelViewModel *homeViewModel = [[ZHomeModelViewModel alloc] init];
            homeViewModel.userModel = userModel;
            
            [self.homeModelList addObject:homeViewModel];
            
        }
        
        if (finishBlacok) {
            
            finishBlacok(YES);
        }
        
    } failure:^(NSError *error) {
        
        if (finishBlacok) {
            
            finishBlacok(NO);
        }
    }];
    
}
@end
